<?php

namespace app\api\model;

use think\Model;
use traits\model\SoftDelete;

class MonthReports extends Model
{
    use SoftDelete;
    protected $deleteTime = 'deletetime';
    protected $hidden = ['deletetime', 'createtime', 'updatetime'];

    public static function getByStudent($student_id, $date)
    {
        $startTime = strtotime(date('Y-m', strtotime($date)));
        $endTime = strtotime("+1 month -1 seconds", $startTime);
        return self::where('student_id', $student_id)->whereTime('createtime', [$startTime, $endTime])->find();
    }
}
